package com.yanqu.road.entity.activity.chefduel.process3;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.yanqu.road.entity.DataObject;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

//阶段1成品食材比赛
public class ChefDuel3Table extends DataObject{

	private int activityId;

	private long userId;

	private int openItemId;

	private int no;//比赛场次

	private long serverId;

	private String joinerData;

	//pos userId
	private Map<Integer,Long> cookBoy3JoinerMap = new ConcurrentHashMap<>();

	private long integral;

	private long openTime;

	private long overTime;

	//我开启的次数
	private int myOpenTimes;

	public int getActivityId() {
		return activityId;
	}

	public void setActivityId(int activityId) {
		this.activityId = activityId;
	}

	public long getUserId() {
		return userId;
	}

	public void setUserId(long userId) {
		this.userId = userId;
	}

	public int getOpenItemId() {
		return openItemId;
	}

	public void setOpenItemId(int openItemId) {
		if(openItemId != this.openItemId){
			this.openItemId = openItemId;
			setUpdateOption();
		}
	}

	public int getNo() {
		return no;
	}

	public void setNo(int no) {
		this.no = no;
	}

	public long getServerId() {
		return serverId;
	}

	public void setServerId(long serverId) {
		this.serverId = serverId;
	}

	public String getJoinerData() {
		if(joinerData != null && cookBoy3JoinerMap != null && cookBoy3JoinerMap.size() > 0){
			joinerData = null;
		}
		return JSON.toJSONString(new HashMap<>(cookBoy3JoinerMap));
//		return joinerData;
	}

	public void setJoinerData(String joinerData) {
		if(!joinerData.equals(this.joinerData)){
			this.joinerData = joinerData;
			this.cookBoy3JoinerMap = JSON.parseObject(joinerData, new TypeReference<ConcurrentHashMap<Integer,Long>>(){});
			setUpdateOption();
		}
	}

	public long getIntegral() {
		return integral;
	}

	public void setIntegral(long integral) {
		if(integral != this.integral){
			this.integral = integral;
			setUpdateOption();
		}
	}

	public long getOpenTime() {
		return openTime;
	}

	public void setOpenTime(long openTime) {
		if(openTime != this.openTime){
			this.openTime = openTime;
			setUpdateOption();
		}
	}

	public long getOverTime() {
		return overTime;
	}

	public void setOverTime(long overTime) {
		if(overTime != this.overTime){
			this.overTime = overTime;
			setUpdateOption();
		}
	}

	public Map<Integer,Long> getChefDuel3JoinerMap() {
		if(this.cookBoy3JoinerMap == null){
			this.cookBoy3JoinerMap = JSON.parseObject(joinerData, new TypeReference<ConcurrentHashMap<Integer,Long>>(){});
		}
		return cookBoy3JoinerMap;
	}

	public void setChefDuel3JoinerMap(Map<Integer,Long> cookBoy3JoinerMap) {
		this.cookBoy3JoinerMap = cookBoy3JoinerMap;
		setUpdateOption();
//		setJoinerData(JSON.toJSONString(cookBoy3JoinerMap));
	}

	public int getMyOpenTimes() {
		return myOpenTimes;
	}

	public void setMyOpenTimes(int myOpenTimes) {
		this.myOpenTimes = myOpenTimes;
	}
}
